package com.wx.auth.util;

import net.sf.json.JSONObject;
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.util.EntityUtils;

import java.io.IOException;

/**
 * Created by sanmao on 2017/6/10.
 */
public class AuthUtil {
    public  static final  String APPID="wxda51cc7f3d579242";
    public  static final  String APPSECRET="ab1322dcaeb9abad49f74cd46aeeeab3";
    public static JSONObject doGetJson(String url) throws IOException {
        JSONObject jsonObject=null;
        DefaultHttpClient client=new DefaultHttpClient();
        HttpGet httpGet=new HttpGet(url);
        HttpResponse response=client.execute(httpGet);
        HttpEntity entity=response.getEntity();
        if(entity!=null){
            String result= EntityUtils.toString(entity,"UTF-8");
            jsonObject=JSONObject.fromObject(result);
        }
        httpGet.releaseConnection();
        return jsonObject;
    }
}
